﻿#include "BoneWeight.h"

namespace DYGraphics
{
	void BoneWeight::Set(int pIndex, float pWeight)
	{
		if (pIndex < 0)
		{
			printf("BoneWeight::Set invalid bone index: %d \n", pIndex);
			return;
		}

		if (pWeight <= 0.00001f)
		{
			printf("BoneWeight::Set invalid weight: %f \n", pWeight);
			return;
		}

		if (boneIndex1 == pIndex || boneIndex2 == pIndex || boneIndex3 == pIndex || boneIndex4 == pIndex)
		{
			printf("BoneWeight::Set bone index already set, index=%d \n", pIndex);
			return;
		}

		if (boneIndex1 == -1)
		{
			boneIndex1 = pIndex;
			boneWeight1 = pWeight;
		}
		else if (boneIndex2 == -1)
		{
			boneIndex2 = pIndex;
			boneWeight2 = pWeight;
		}
		else if (boneIndex3 == -1)
		{
			boneIndex3 = pIndex;
			boneWeight3 = pWeight;
		}
		else if (boneIndex4 == -1)
		{
			boneIndex4 = pIndex;
			boneWeight4 = pWeight;
		}
		else
		{
			printf("BoneWeight::Set support bone weight max count is 4, index=%d, weight=%f \n", pIndex, pWeight);
		}
	}
}